package com.topvision.controller.app;

import com.topvision.model.glass.Sysupload;
import com.topvision.util.R;
import io.swagger.annotations.Api;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

@RestController
@Api(value = "开发者测试接口", description = "接口测试")
@RequestMapping("app/test")
public class AppTestController {

//    static {
//        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
//        //注意程序运行的时候需要在VM option添加该行 指明opencv的dll文件所在路径
//        //-Djava.library.path=$PROJECT_DIR$\opencv\x64
//    }

    /**
     * 模拟数据
     *
     * @return
     */
    @RequestMapping(value = "/restoreData", method = RequestMethod.GET)
    public R test() {
        List<Sysupload> result = new ArrayList<>();
        Sysupload sysupload = new Sysupload();
        sysupload.setFilefullpath("http://www.baidu.com");
        result.add(sysupload);

        Sysupload sysupload2 = new Sysupload();
        sysupload2.setFilefullpath("http://www.baidu.com4");
        result.add(sysupload2);

        return R.success(result);
    }


    //素描
    @RequestMapping(value = "/sketchingFace", method = RequestMethod.GET)
    public R sketchingFace() {
        String path = "E:/topvisionupload/face/face0.jpg";
//        Mat mat = Imgcodecs.imread(path);
//        //转灰度图片
//
//        System.out.println(mat);
//        //读取本地图片输入流
//        try {
//
//            FileInputStream inputStream = new FileInputStream(path);
//            BufferedImage sourceImg = ImageIO.read(inputStream);
//            int size = inputStream.available();
//            //byte数组用于存放图片字节数据
//            byte[] buff = new byte[size];
//            inputStream.read(buff);
//            System.out.print("with="+sourceImg.getWidth()+",height="+sourceImg.getHeight());
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        return R.success();
    }


}
